<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + " ://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<jsp:include page="root_public.jsp"/>
<title>主页</title>
</head>

<body>
<!-- 顶部开始 -->
<div class="container">
    <div class="logo">
        <a href="<%=path%>/rootIndex">失物招领后台管理系统</a>
    </div>
    <div class="left_open" style="margin-left: 20px;">
        <i title="展开左侧栏" class="iconfont">&#xe699;</i>
    </div>
    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item">
            <a href="javascript:;" class="userName"></a>
            <a href="javascript:;" class="userId" style="display: none;position:absolute;"></a>
            <dl class="layui-nav-child">
                <!-- 二级菜单 -->
                <dd>
                    <a onclick="x_admin_show('个人信息','<%=path%>/self',450,400)">个人信息</a>
                </dd>
                <dd>
                    <a onclick="x_admin_show('修改密码','<%=path%>/selfPwd',400,300)">修改密码</a>
                </dd>
                <dd>
                    <a href="<%=path%>/sys/logout">退出</a>
                </dd>
            </dl>
        </li>
        <li class="layui-nav-item to-index">
            <a href="<%=path%>/rootIndex">前台首页</a>
        </li>
    </ul>

</div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<!-- 左侧菜单开始 -->
<div class="left-nav">
    <div id="side-nav">
        <ul id="nav">
        </ul>
    </div>
</div>

<!-- <div class="x-slide_left"></div> -->
<!-- 左侧菜单结束 -->
<!-- 右侧主体开始 -->
<div class="page-content">
    <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
        <ul class="layui-tab-title">
            <li>我的桌面</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <iframe src='<%=path%>/welcome' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
            </div>
        </div>
    </div>
</div>
<div class="page-content-bg"></div>
<!-- 右侧主体结束 -->
<!-- 中部结束 -->
<!-- 底部开始 -->
<div class="footer">
    <div class="copyright">Copyright ©2017 2015届软件五班TooNice-Team All Rights Reserved</div>
</div>
<!-- 底部结束 -->
<script>
    /*
    * 获取个人信息
    * */
    $.ajax({
        type: "post",
        url: "<%=path%>/user/findSelf",
        async: true,
        dataType: "json",
        success: function (data) {
            var datas = data.data.user;
            $('.userName').text(datas.name);
            $('.userId').text(datas.id);
        }
    });
    /*
    * 获取个人菜单
    * */
    var $nav = $('#nav');
    $.ajax({
        type: "post",
        url: "<%=path%>/menu/findSelfMenu",
        async: true,
        dataType: "json",
        success: function (data) {
            var datas = data.data.menuList,
                $xiframe = $('.x-iframe'),
                iconArray = ['&#xe705;', '&#xe857;', '&#xe60a;', '&#xe62d;', '&#xe638;', '&#xe63c;',
                    '&#xe634;', '&#xe62e;', '&#xe629;'];
            $nav.html("");
            var i = datas.length - 1;
            for (i; i >= 0; --i) {
                var datass = datas[i];
                if (datass.isShow === "0") {
                    continue;
                }
                switch (parseInt(datass.id)) {
                    case 2: {
                        var $html = $('<li>\n' +
                            '                <a _href="<%=path%>/' + datass.href + '">\n' +
                            '                    <i class="iconfont">&#xe6ce;</i>\n' +
                            '                    <cite>' + datass.name + '</cite>\n' +
                            '                    <i class="iconfont nav_right">&#xe697;</i>\n' +
                            '                </a>\n' +
                            '            </li>');
                        $nav.append($html);
                    }
                        break;
                    case 3: {
                        var $html = $('<li>\n' +
                            '                    <a _href="<%=path%>/' + datass.href + '">\n' +
                            '                        <i class="iconfont">&#xe726;</i>\n' +
                            '                    <cite>' + datass.name + '</cite>\n' +
                            '                    <i class="iconfont nav_right">&#xe697;</i>\n' +
                            '                    </a>\n' +
                            '                    </li>');
                        $nav.append($html);
                    }
                        break;
                    case 4: {
                        var $html = $('<li>\n' +
                            '                    <a _href="<%=path%>/' + datass.href + '">\n' +
                            '                        <i class="iconfont">&#xe6b8;</i>\n' +
                            '                    <cite>' + datass.name + '</cite>\n' +
                            '                    <i class="iconfont nav_right">&#xe697;</i>\n' +
                            '                    </a>\n' +
                            '                    </li>');
                        $nav.append($html);
                    }
                        break;
                    case 5: {
                        var $html = $('<li>\n' +
                            '                    <a _href="<%=path%>/' + datass.href + '">\n' +
                            '                        <i class="iconfont">&#xe723;</i>\n' +
                            '                    <cite>' + datass.name + '</cite>\n' +
                            '                    <i class="iconfont nav_right">&#xe697;</i>\n' +
                            '                    </a>\n' +
                            '                    </li>');
                        $nav.append($html);
                    }
                        break;
                    default: {
                        var ii = parseInt((iconArray.length - 1) * Math.random());
                        var $html = $('<li>\n' +
                            '                <a _href="<%=path%>/' + datass.href + '">\n' +
                            '                    <i class="iconfont">' + iconArray[ii] + '</i>\n' +
                            '                    <cite>' + datass.name + '</cite>\n' +
                            '                    <i class="iconfont nav_right">&#xe697;</i>\n' +
                            '                </a>\n' +
                            '            </li>');
                        $nav.append($html);
                    }
                        break;
                }
            }
            $nav.children('li').click(function () {
                $xiframe.attr("src", $(this).children('a').attr("_href"));
            })
        }
    });
</script>
</body>

</html>